package com.xfatm.simplebrowser.ui;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.xfatm.simplebrowser.MainActivity;
import com.xfatm.simplebrowser.R;

/**
 * Created by wenjie on 2018/3/13.
 */

public class BottomDialog extends Dialog{
    private Dialog self=this;
    public BottomDialog(@NonNull Context context) {
        super(context, R.style.BottomDialog);
        setContentView(R.layout.bottom_menu);
        Window dialogWindow = getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes(); // 获取对话框当前的参数值
        lp.x = 0; // 新位置X坐标
        lp.y = 0; // 新位置Y坐标
        lp.width = context.getResources().getDisplayMetrics().widthPixels; // 宽度

        lp.alpha = 10f; // 透明度
        dialogWindow.setAttributes(lp);

        Button downloadManage=findViewById(R.id.downloadManage);
        downloadManage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("sout","哈哈哈");
            }
        });

        //退出按钮
        Button exitBtn=findViewById(R.id.exit);
        exitBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                System.exit(0);
            }
        });
        //设置按钮
        Button settingBtn=findViewById(R.id.setting);
        settingBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(v.getContext(),SettingActivity.class);
                v.getContext().startActivity(intent);
                self.hide();
            }
        });
        //下载按钮
        findViewById(R.id.downloadManage).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(v.getContext(),DownLoadActivity.class);
                v.getContext().startActivity(intent);
                self.hide();
            }
        });
    }
}
